/**
 *
 *! \file        def_tag.h
 * \brief This module contains the definition of tags used in EMV Package
 *
 *
 * \author        SMO
 * \author Copyright (c) 2001 Sagem Monetel SA, rue claude Chappe,
 * \author 07503 Guilherand-Granges, France, All Rights Reserved.
 *
 * \author Sagem Monetel SA has intellectual property rights relating
 * \author to the technology embodied in this software.  In particular,
 * \author and without limitation, these intellectual property rights
 * \author may include one or more patents.
 *
 * \author This software is distributed under licenses restricting
 * \author its use, copying, distribution, and decompilation.
 * \author No part of this software may be reproduced in any form
 * \author by any means without prior written authorization of
 * \author Sagem Monetel.

 *
 */

#ifndef _DEFTAG_H
#define _DEFTAG_H


/*
**************************************************************************
**	Elements given by ENGINE
**************************************************************************
*/
/** @defgroup IntTags Internal Tags Definition
 *  @{											*/
/** @defgroup Entags Tags Emitted by Engine Component
 *  @{											*/
/**@def TAG_EG_IDENTIFICATION
 * @brief Engine identification on 11 bytes

	- CRC on 2 bytes
	- Component type on 1 byte
	- Component name on 8 bytes 	*/
#define TAG_EG_IDENTIFICATION		0x9F8701
#define TAG_EG_VERSION				0x9F8702	/**< Engine Version. On 2 bytes */
#define TAG_EG_MESSAGE_CODE_NUM		0x9F8703	/**< message code number. On 2 bytes : ID of standard message to display */
#define TAG_EG_CARDHOLDER_LANGUAGE	0x9F8704	/**< Language to use. On 2 bytes represented by 2 alphabetical characters according to ISO 639 */
#define TAG_EG_NUM_APPLI			0x9F8705	/**< Engine Application type, on 1 byte (given by M2OS) */
/**@def TAG_EG_IS_AMOUNT_NEEDED
 * @brief When beginning a transaction, indicates to Custom if it is necessary to enter the amount

  Length = 1 byte.
	- TRUE	: Engine asks Custom for an amount entry
	- FALSE	: Amount is already available. No amount entry needed 	*/
#define TAG_EG_IS_AMOUNT_NEEDED		0x9F8706
/**@def TAG_EG_REFERRAL_CARD
 * @brief Referral origin

  Length = 1 byte.
	- TRUE	: Referral asked by the card
	- FALSE	: Referral asked by the issuer 	*/
#define TAG_EG_REFERRAL_CARD		0x9F8707

#define TAG_EG_IS_PIN_ONLINE_ACCEPTED    0x9f8720

/*& BEGIN TEDT/Z3/02/1259/PBE								*/
#define TAG_EG_TYPE_KEY_PRESSED    0x9f8721	/**< Key value, given by M20S in the entry-point keyboard_event. */
/*& END TEDT/Z3/02/1259/PBE								*/
/*& BEGIN SMO/ETU/05/20085/LB                                              */
/**@def TAG_EG_DISPLAY_DESTINATION
 * @brief When a message is displayed, indicates the destination

  Length = 1 byte.
	- #DISPLAY_CARDHOLDER
	- #DISPLAY_MERCHANT
	- DISPLAY_MERCHANT_CARDHOLDER                      */
#define TAG_EG_DISPLAY_DESTINATION		0x9F8722

#define DISPLAY_MERCHANT            0 /* Display on the merchant device    */
#define DISPLAY_CARDHOLDER          1 /* Display on the cardholder device  */
#define DISPLAY_MERCHANT_CARDHOLDER 2 /* Display on both devices           */
/*& END SMO/ETU/05/20085/LB                                                */
/** @} */ // end of Tags Emitted by Engine

/*
**************************************************************************
**	Elements given by CUSTOM
**************************************************************************
*/

/** @defgroup Cutags Tags Emitted by EMV Custom Component
 *  @{											*/
/** @defgroup CuStat Custom Service Status Codes
 *  @{											*/
/**@def TAG_CUST_STATUS_CODE
 * @brief EMV Custom service status code. Coded on 2 bytes.
 	*/
#define TAG_CUST_STATUS_CODE				0x9F8401
/** @} */ // end of CuStat
/**@def TAG_CUST_APPLI_NAME
 * @brief Name of EMV application, displayed by M2OS. Name on 8 alphanumeric bytes
 	*/
#define TAG_CUST_APPLI_NAME					0x9F8402
/**@def TAG_CUST_IDLE_MESSAGE
 * @brief Idle message to be displayed, if no other application is present. Name on 16 alphanumeric bytes
 	*/
#define TAG_CUST_IDLE_MESSAGE				0x9F8403
/**@def TAG_CUST_IDENTIFICATION
 * @brief EMV Custom identification on 11 bytes

	- CRC on 2 bytes
	- Component type on 1 byte
	- Component name on 8 bytes 	*/
#define TAG_CUST_IDENTIFICATION				0x9F8404
#define LEN_CUST_IDENTIFICATION				11
#define TAG_CUST_VERSION					0x9F8405
#define LEN_CUST_VERSION					2

#define TAG_NB_AID_TERMINAL					0x9F8407	/**< Number of AID managed by the application. length = 1 byte */
#define TAG_CUST_IS_KSU						0x9F8408	/**< Obsolete value. Not used any more */
#define TAG_CUST_IS_BLACK_LIST				0x9F8409	/**< Obsolete value. Not used any more */
#define TAG_CUST_IS_PIN_BYPASS				0x9F840A	/**< Obsolete value. Not used any more */
#define TAG_CUST_IS_ONLINE_ADVICE			0x9F840B	/**< Obsolete value. Not used any more */
#define TAG_CUST_IS_OFFLINE_ADVICE			0x9F840C
#define TAG_CUST_IS_VOICE_REFERRAL			0x9F840D
#define TAG_CUST_IS_FORCED_ONLINE			0x9F840E	/**< Boolean True if advice are supported and generate an off-line message. Length = 2 bytes. */
#define TAG_CUST_IS_FORCED_ACCEPTANCE		0x9F840F	/**< Boolean True if the merchant is allowed to force the transaction to go online. Length = 2 bytes. */
#define TAG_CUST_IS_ONLINE_ADVICE_IF_FORCED_ACCEPTANCE	0x9F8410
#define TAG_CUST_COMM_TYPE_APPLI			0x9F8411
#define TAG_CUST_NEW_BLACK_LIST_NEEDED		0x9F8412	/**< Boolean True if CUSTOM wishes to receive a new black-list. Length = 2 bytes. */
#define TAG_CUST_PIN_BYPASS_REQUEST			0x9F8413
#define TAG_CUST_FORCED_ONLINE_REQUEST		0x9F8414	/**< Boolean  True if the merchant asked to force the transaction to go online. Length = 2 bytes. */
#define TAG_CUST_FORCED_ACCEPTANCE_REQUEST	0x9F8415	/**< Boolean  True if the merchant is allowed to force the acceptance of the transaction. Length = 2 bytes. */
#define TAG_LAST_TR_AMOUNT_BIN				0x9F8416	/**< Amount of the last transaction. Binary value on 4 bytes. (most significant byte is byte 0)  */
#define TAG_LAST_TR_CURRENCY_CODE			0x9F8417	/**< Currency code of the last transaction. Length = 2 bytes */
#define TAG_LAST_TR_DATE					0x9F8418
#define TAG_LAST_TR_TIME					0x9F8419
#define TAG_LAST_TR_TYPE					0x9F841A
#define TAG_CUST_PAN_IN_BLACK_LIST			0x9F841B	/**< Boolean, True if CUSTOM find the PAN in the exception file. Length = 2 bytes */
#define TAG_CUST_NB_RECORD_IN_BATCH			0x9F841C	/**< Number of records present in the batch file. Bynary value on 4 bytes */
/*& BEGIN TEDT/Z3/02/927/LB                                  */
/**@def TAG_CUST_APPLICATION_SELECTION_ID
 * @brief Application Selection Indicator. See EMV 2000, Book 1, 8.3

	Length : 1 byte
	- 0 : Multiple occurences of the application are not allowed in the card : Partial name not supported
	- 1 : Multiple occurences of the application are allowed in the card : Partial supported	*/
#define TAG_CUST_APPLICATION_SELECTION_ID	0x9F841D
/*& END TEDT/Z3/02/927/LB                                    */
/*&BEGIN FT 472/MA TRM can be bypassed */
#define TAG_CUST_TRM_OVERPASS_AIP		   0x9F841E	/**< Boolean TRM to be done without testing AIP if TRUE */

#define TAG_CUST_SERVICE_AUTHO_NUM			0x9F8420	/**< Obsolete value. Not used any more */
/**@def TAG_CUST_DEBIT_IS_ASKED
 * @brief Boolean given in response to a function called by menu

	Length : 2 bytes. True if Engine must start a transaction */
#define TAG_CUST_DEBIT_IS_ASKED				0x9F8421

/*& BEGIN FT/937/06/MA : Get transaction Log from ICC for PBOC			   */
/**@def TAG_CUST_TRLOG_IS_ASKED
 * @brief Boolean given in response to a function called by menu

	Length : 2 bytes. True if Engine must start a transaction log */
#define TAG_CUST_TRLOG_IS_ASKED				0x9F842C
/*& END FT/937/06/MA : Get transaction Log from ICC for PBOC			   */

/*&BEGIN FT/07/1567/MA : force transaction type for PR     */
/**@def TAG_CUST_FORCE_OTHER_TT
 * @brief Boolean given in response to a function called by menu

	Length : 2 bytes. True if Engine must force transaction type to 00 */
#define TAG_CUST_FORCE_OTHER_TT				0x9F842D
/*&END FT/07/1567/MA : force transaction type for PR     */



#define TAG_CUST_IS_COMMUNICATION_OK		0x9F8422	/**< Boolean, In case of on-line authorisation, indicates if the communication succeeded. Length = 2 bytes */
/*& BEGIN TEDT/Z3/02/1060/PBE								*/
#define TAG_CUST_KEY_VALIDITY_DATE			0x9F8423
/*& END TEDT/Z3/02/1060/PBE								*/
/*& BEGIN TEDT/Z3/02/1157/PBE								*/
/**@def TAG_CUST_CERTIF_SERIAL_NO
 * @brief Serial Number of a certificate.

	Binary number unique to a certificate assigned by the certification authority. See EMV 2000, Book 2, 6.1
	Length : 3 bytes. binary */
#define TAG_CUST_CERTIF_SERIAL_NO			0x9F8424
/** @defgroup Curevok List of revoked certificates
	List of revoked Issuer Public Key Certificates.

	See EMV 2000, Book2, 5.4, bullet 10.
	The following 5 tags contain a concatened list of revoked certificate. Up to 255 bytes are
	available for each tag.
	9 bytes are used per certificate :
	- RID of certification authority : 5
	- Certification Authority Key Index : 1
	- Serial Number of the certificate :3
 *  @{											*/
#define TAG_CUST_CA_REVOK_1					0x9F8425	/**< First tag to use to fill in the list */
#define TAG_CUST_CA_REVOK_2					0x9F8426	/**< Second tag Use only if previous one it full */
#define TAG_CUST_CA_REVOK_3					0x9F8427	/**< third tag Use only if previous ones are full */
#define TAG_CUST_CA_REVOK_4					0x9F8428	/**< fourth tag Use only if previous ones are full */
#define TAG_CUST_CA_REVOK_5					0x9F8429	/**< fifth tag Use only if previous ones are full */
/** @} */ // end of Curevok
/*& END TEDT/Z3/02/1157/PBE								*/

/*& BEGIN RA TEDT/Z3/02/1608/PBE  */
#define TAG_TRANSACTION_FORCED_ACCEPTANCE    0x9F842A	/**< Boolean, True if the merchant wants to force the tranaction acceptance. Length = 1 byte */
/*& END RA TEDT/Z3/02/1608/PBE  */

/*& BEGIN DE TEDT/Z2/03/585/LB                                             */
/**@def TAG_CUST_POS_ISO8583_93
 * @brief Point of Service Code of Data (ISO 8583 -1993).

	12 characters, as defined in ISO 8583 - 1993	 */
#define TAG_CUST_POS_ISO8583_93	             0x9F842B
#define LEN_CUST_POS_ISO8583_93	             12
/*& END DE TEDT/Z2/03/585/LB                                               */

/*& BEGIN DE SMO/ETU/03/20004/LB                                           */
/**@def TAG_CUST_IS_COMM_MANAGED_BY_CUSTOM
 * @brief Indicates if Custom manages all the interface with the host acquirer.

	For historical reasons, EMV Engine manages authorisation requests during the transaction.
	It calls standard COMM entry points to achieve these authorisation requests.
	It may be useful in some cases to let Custom manage fully the interface with the acquirer host.
	In this case, set this tag on, and send it to Engine in global parameters.
	EMV ENGINE will then call the service EMVCUST_Authorisation instead of the corresponding COMM service.

	Length = 1 byte.
*/
#define TAG_CUST_IS_COMM_MANAGED_BY_CUSTOM   0x9F8430
#define LEN_CUST_IS_COMM_MANAGED_BY_CUSTOM   1
/*& END DE SMO/ETU/03/20004/LB                                             */

/*& BEGIN DE SMO/ETU/05/20085/LB                                           */
/**@def TAG_CUST_SUPPORTED_LANGUAGE_LIST
 * @brief Gives the list of the languages supported by the terminal

	This tag contains the list of supported languages. Each language is represented
	by 2 alphabetical characters, according to ISO 639.
	This tag shall be given to EMV Engine in the service EMVCUST_Get_Global_Param.

	Length = N * 2 bytes (N is the number of supported languages)
*/
#define TAG_CUST_SUPPORTED_LANGUAGE_LIST   0x9F8431
/*& END DE SMO/ETU/05/20085/LB                                             */

/*& BEGIN SMO/ETU/04/20344/MA :                                            */
/* Set of tag created to manage configuration file                         */
#define TAG_CUST_IS_PREFERRED_DISPLAY_ORDER   0x9F8440
#define TAG_CUST_IS_MULTILANG_SUPPORTED		  0x9F8441
#define TAG_CUST_IS_REVOK_SUPPORTED			  0x9F8442
#define TAG_CUST_IS_AMOUNT_BEFORE_CVM		  0x9F8443
#define TAG_CUST_IS_TRANSACTION_LOG			  0x9F8444
#define TAG_CUST_IS_ISSUER_REFERRAL			  0x9F8445
#define TAG_CUST_IS_CARD_REFERRAL			  0x9F8446
#define TAG_CUST_IS_BATCH_CAPTURE			  0x9F8447
#define TAG_CUST_IS_ONLINE_CAPTURE			  0x9F8448
#define TAG_CUST_IS_PINPAD					  0x9F8449
#define TAG_CUST_IS_AMOUNT_PIN_SAME			  0x9F844A
#define TAG_CUST_IS_CARDHOLDER_CONFIRMATION	  0x9F844B
#define TAG_CUST_IS_EXCEPTION_FILE			  0x9F844C
#define TAG_CUST_IS_GETDATA_PIN_TRY_COUNTER	  0x9F844D
#define TAG_CUST_IS_POS_ENTRY_MODE			  0x9F844E
#define TAG_CUST_POS_ENTRY_VALUE			  0x9F844F
#define TAG_CUST_IS_CONFIG_FILE				  0x9f8450
#define TAG_CUST_CRC_CONFIG_FILE			  0x9f8451

#define TAG_CUST_IS_DEFAULT_DDOL			  0x9F8452
#define TAG_CUST_IS_FLOOR_LIMIT_CHECKING	  0x9F8453
#define TAG_CUST_IS_RANDOM_TRANSACTION_SELECT 0x9F8454
#define TAG_CUST_IS_VELOCITY_CHECKING		  0x9F8455
#define TAG_CUST_IS_DEFAULT_TDOL			  0x9f8456
#define TAG_CUST_FULL_CRC_CONFIG_FILE		  0x9f8457
/*& END SMO/ETU/04/20344/MA                                                */
#define TAG_CUST_IS_ODA_PROCESSING	  		  0x9F8458
#define TAG_CUST_IS_ACCOUNT_TYPE			  0x9F8459
#define TAG_CUST_IS_SKIP_DEFAULT	  		  0x9F845A
#define TAG_CUST_IS_SKIP_ONLINE	  		  	  0x9F845B


/*& BEGIN FT/2006/07/MA :  CDA Modified Terminal Behaviour			   */
#define TAG_CUST_DETECT_FAIL_PRIOR_TAA	    0x9F845C
#define TAG_CUST_CDA_NEVER_REQUEST_ARQC_1GENAC 	0x9F845D
#define TAG_CUST_CDA_NEVER_REQUEST_ONLINE_2GENAC 0x9F845E
/*& BEGIN FT/2006/07/MA :  CDA Modified Terminal Behaviour			   */



/* *************************** */
/*     Service Status Code     */
/* *************************** */
/** @defgroup CuStat Custom Service Status Codes
 *  @{											*/

/* Service Completed Successfully */
/*
#define	TAG_CUST_PROCESS_COMPLETED				0x0000
#define	TAG_CUST_TRANSACTION_ACCEPTED			0x0001
#define TAG_CUST_TRANSACTION_DECLINED			0x0002
#define	TAG_CUST_AUTHORISATION_REQUEST			0x0003
#define	TAG_CUST_REFERRAL_REQUEST				0x0004
#define	TAG_CUST_VISA_EASY_ENTRY_CARD			0x0005
#define TAG_CUST_RETRY_COMMUNICATION			0x0006
*/
#define	TAG_CUST_PROCESS_COMPLETED				TAG_PROCESS_COMPLETED
#define	TAG_CUST_TRANSACTION_ACCEPTED			TAG_TRANSACTION_ACCEPTED
#define TAG_CUST_TRANSACTION_DECLINED			TAG_TRANSACTION_DECLINED
#define	TAG_CUST_AUTHORISATION_REQUEST			TAG_AUTHORISATION_REQUEST
#define	TAG_CUST_REFERRAL_REQUEST				TAG_REFERRAL_REQUEST
#define	TAG_CUST_VISA_EASY_ENTRY_CARD			TAG_VISA_EASY_ENTRY_CARD
/*
#define TAG_CUST_RETRY_COMMUNICATION			0x0086
*/
#define TAG_CUST_RETRY_COMMUNICATION			0x0008

#define TAG_CUST_CDA_FAILED						TAG_CDA_FAILED


/* Transaction Terminated */
#define TAG_CUST_TRANSACTION_CANCELLED			0x0010
#define TAG_CUST_PROCESSING_ERROR				0x0011
#define TAG_CUST_CARD_ERROR						0x0012
#define	TAG_CUST_NOT_ACCEPTED					0x0013
#define TAG_CUST_ICC_DATA_FORMAT_ERROR			0x0014
#define TAG_CUST_MISSING_MANDATORY_ICC_DATA		0x0015
#define TAG_CUST_ICC_REDUNDANT_DATA				0x0016
#define TAG_CUST_CARD_BLOCKED					0x0017
#define TAG_CUST_COND_OF_USE_NOT_SATISFIED		0x0018
#define TAG_CUST_MISSING_MANDATORY_TERM_DATA	0x0019
#define TAG_CUST_INTERNAL_ERROR					0x001A
#define TAG_CUST_REMOVED_CARD					0x001B


/* Service execution error */
#define	TAG_CUST_NOT_ENOUGH_MEMORY					0x0101
#define	TAG_CUST_WRONG_DEL_INPUT_PARAMETER			0x0102
#define	TAG_CUST_SERVICE_NOT_AVAILABLE  			0x0103
#define	TAG_CUST_PAN_NOT_FOUND          			0x0104
#define	TAG_CUST_NEW_PARAMETERS      			    0x0105
#define	TAG_CUST_REFERRAL_DECLINED     			    0x0106
#define	TAG_CUST_REFERRAL_ON_LINE     			    0x0107
/*& BEGIN SMO/ETU/05/20339/MA                                    */
#define	TAG_CUST_REFERRAL_NOT_ACCEPTED 			    0x0108
/*& END SMO/ETU/05/20339/MA                                      */
/** @} */ // end of CuStat
/** @} */ // end of Tags Emitted by Custom



/* *************************** */
/*     Service Status Code     */
/* *************************** */

/* Service Completed Successfully */
#define	TAG_COMM_PROCESS_COMPLETED				0x0000
#define	TAG_COMM_ERASE_BATCH_DATE				0x0001
#define	TAG_COMM_ERASE_BATCH_COUNTER			0x0002

/* Service execution error */
#define	TAG_COMM_SERVICE_NOT_AVAILABLE			0x0103
#define	TAG_COMM_HOST_UNREACHABLE				0x0104
#define	TAG_COMM_COMM_PROBLEM					0x0105
#define	TAG_COMM_COMM_TIME_OUT					0x0106
#define	TAG_COMM_MESSAGE_REJECTED				0x0107
#define	TAG_COMM_INVALID_RESPONSE				0x0108
#define TAG_COMM_MERCHANT_CANCEL                0x0109

/*& BEGIN DE TE/Z2/03/46/JMV : REVERSAL */

/* Valid values for reversal messages */
#define	TAG_COMM_CUSTOMER_CANCELLATION			0x01
#define	TAG_COMM_SUSPECTED_MALFUNCTION			0x02
#define	TAG_COMM_RESPONSE_RECEIVED_TOO_LATE		0x03
#define	TAG_COMM_TIMED_OUT_AT_TAKING_MONEY		0x04
#define	TAG_COMM_TIME_OUT_WAITING_FOR_RESPONSE	0x05
#define	TAG_COMM_ICC_GENERATED_ACC				0x06

/*& END DE TE/Z2/03/46/JMV : REVERSAL */


#define TAG_APPLICATION_LIST	0x9F8200
#define TAG_EMV_SELECTED_AID	0x9F8201

/** @} */ // end of Internal Tags Definition


#endif
